﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.ComponentModel;

namespace Oroboros.Save_Data
{
    [XmlRootAttribute(ElementName = "GameSaveData", IsNullable = false)]
    public class GameSaveData : INotifyPropertyChanged
    {
        private ZombieClockSaveData _ZombieClock;
        private BaseManagerSaveData _BaseManager;
        private CharacterUsageSaveData _CharacterUsage;
        private int _DailyMissionCount;
        private HumanManagerSaveData _HumanManager;
        private long _LastBaseAttackTimeTicks;
        private MapSaveData _Map;
        private MissionLevelUsageSaveData _MissionLevelUsage;
        private int _MissionRandomSeed;
        private long _MissionReturnTimeLimitTicks;
        private int _NextMissionRandomSeed;
        private ScoreKeeperSaveData _ScoreKeeper;
        private DailyEventsSaveData _DailyEvents;

        public DailyEventsSaveData DailyEvents { get { return _DailyEvents; } set { Changed("DailyEvents"); _DailyEvents = value; } }
        public ZombieClockSaveData ZombieClock { get { return _ZombieClock; } set { Changed("ZombieClock"); _ZombieClock = value; } }
        public BaseManagerSaveData BaseManager { get { return _BaseManager; } set { Changed("BaseManager"); _BaseManager = value; } }
        public CharacterUsageSaveData CharacterUsage { get { return _CharacterUsage; } set { Changed("CharacterUsage"); _CharacterUsage = value; } }
        public int DailyMissionCount { get { return _DailyMissionCount; } set { Changed("DailyMissionCount"); _DailyMissionCount = value; } }
        public HumanManagerSaveData HumanManager { get { return _HumanManager; } set { Changed("HumanManager"); _HumanManager = value; } }
        public long LastBaseAttackTimeTicks { get { return _LastBaseAttackTimeTicks; } set { Changed("LastBaseAttackTimeTicks"); _LastBaseAttackTimeTicks = value; } }
        public MapSaveData Map { get { return _Map; } set { Changed("Map"); _Map = value; } }
        public MissionLevelUsageSaveData MissionLevelUsage { get { return _MissionLevelUsage; } set { Changed("MissionLevelUsage"); _MissionLevelUsage = value; } }
        public int MissionRandomSeed { get { return _MissionRandomSeed; } set { Changed("MissionRandomSeed"); _MissionRandomSeed = value; } }
        public long MissionReturnTimeLimitTicks { get { return _MissionReturnTimeLimitTicks; } set { Changed("MissionReturnTimeLimitTicks"); _MissionReturnTimeLimitTicks = value; } }
        public int NextMissionRandomSeed { get { return _NextMissionRandomSeed; } set { Changed("NextMissionRandomSeed"); _NextMissionRandomSeed = value; } }
        public ScoreKeeperSaveData ScoreKeeper { get { return _ScoreKeeper; } set { Changed("ScoreKeeper"); _ScoreKeeper = value; } }

        public GameSaveData() { }

        public event PropertyChangedEventHandler PropertyChanged;
        public void Changed(string n)
        {
            if (PropertyChanged == null) return;
            if (!string.IsNullOrEmpty(n))
                PropertyChanged(this, new PropertyChangedEventArgs(n));
        }

        public DateTime LastBaseAttackTime { get { return new DateTime(_LastBaseAttackTimeTicks); } set { Changed("LastBaseAttackTime"); _LastBaseAttackTimeTicks = value.Ticks; } }
        public TimeSpan MissionReturnTimeLimit { get { return new TimeSpan(_MissionReturnTimeLimitTicks); } set { Changed("MissionReturnTimeLimit"); _MissionReturnTimeLimitTicks = value.Ticks; } }
    }
}
